import config from '@/config'
import RequestBase from '@/utils/request.js'

const baseRequest = new RequestBase(config.baseUrl)
const safetyRequest = new RequestBase(config.safetyUrl)
export const listDept = (searchKey) => {
  const data = {
    deptName: searchKey,
    pageSize: 9999
  }
  return baseRequest.get('/system/dept/list', data)
}
// 部门用户数包含子部门的用户
export const listDeptChildren = (searchKey) => {
  const data = {
    containUnAssign: false, // 不包含管理员
    containChildren: true, // 包含子部门人员数量
    deptName: searchKey,
    pageSize: 9999,
    withCount: true
  }
  return baseRequest.get('/portal/auth/dept/api/v1/tree', data)
}

// 部门用户数包含子部门的用户
export const reqDeptData = (params = {}) => {
  const data = {
    ...params
  }
  return baseRequest.get('/portal/auth/dept/api/v1/tree', data)
}

// 根据id 获取部门信息
export const getDept = (deptId) => {
  return baseRequest.get(`/portal/auth/dept/api/v1/detail/${deptId}`)
}

// 承包商
export const getContractor = (params) => {
  const data = {
    filterBlackList: true,
    presentStatus: 1,
    status: 2,
    pageSize: 9999
  }
  return safetyRequest.get('/bsci/contractor/list', data)
}
